package org.example.servicepay.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;

/**
 * 二维码支付结果响应
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PaymentResponse {
    
    /**
     * 二维码支付地址
     */
    private String qrcodeUrl;
    
    /**
     * 商户订单号
     */
    private String outTradeNo;
    
    /**
     * 支付状态
     */
    private String status;
    
    /**
     * 提示信息
     */
    private String message;
    
    /**
     * 查询结果数据（用于查询支付结果接口）
     */
    private Map<String, Object> data;
    
    public PaymentResponse(String qrcodeUrl, String outTradeNo, String status, String message) {
        this.qrcodeUrl = qrcodeUrl;
        this.outTradeNo = outTradeNo;
        this.status = status;
        this.message = message;
    }
    
    public static PaymentResponse success(String qrcodeUrl, String outTradeNo, String message) {
        return new PaymentResponse(qrcodeUrl, outTradeNo, "SUCCESS", message);
    }
    
    public static PaymentResponse successWithData(Map<String, Object> data, String outTradeNo, String message) {
        PaymentResponse response = new PaymentResponse();
        response.setData(data);
        response.setOutTradeNo(outTradeNo);
        response.setStatus("SUCCESS");
        response.setMessage(message);
        return response;
    }
    
    public static PaymentResponse fail(String outTradeNo, String message) {
        return new PaymentResponse(null, outTradeNo, "FAIL", message);
    }
}